package vip.xiaonuo.smzq.modular.hisi.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.smzq.modular.hisi.entity.Kshz;
import vip.xiaonuo.smzq.modular.hisi.entity.vo.*;
import vip.xiaonuo.smzq.modular.hisi.service.IKshzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.smzq.modular.nbfb.entity.param.NbfbSixParam;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;


/**
 * 矿山信息汇总
 *
 * @author sqq
 * @since 2024-07-04
 */
@Api(tags = "矿山信息汇总")
@RestController
@RequestMapping("/hisi/kshz")
@Validated
public class KshzController {

    @Resource
    private IKshzService iKshzService;

    /**
     * 添加矿山信息汇总
     */
    @ApiOperation("添加矿山信息汇总")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Kshz kshz) {
        iKshzService.save(kshz);
        return CommonResult.ok();
    }

    /**
     * 删除矿山信息汇总
     */
    @ApiOperation("删除矿山信息汇总")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iKshzService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑矿山信息汇总
     */
    @ApiOperation("编辑矿山信息汇总")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Kshz kshz) {
        iKshzService.updateById(kshz);
        return CommonResult.ok();
    }

    /**
     * 矿山信息汇总分页查询
     */
    @ApiOperation("矿山信息汇总分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Kshz>> page() {
        return CommonResult.data(iKshzService.page(new Kshz()));
    }


    /**
     * 查询统计-矿山信息查询
     */
     @ApiOperation("查询统计-矿山信息查询")
     @PostMapping("/queryKshzPage")
    public CommonResult<Page<KsxxhzVo>> queryKshzPage(@RequestPart(value = "file", required = false) MultipartFile file, // 新增：接收文件流
                                                      @Validated  CxtjMhtj cxtjMhtj) {
        return CommonResult.data(iKshzService.queryKshzPage(cxtjMhtj,file));
    }

    /**
     * 下载查询条件模版
     *
     * @param response
     * @author sqq
     * @since 2025/3/31 9:54
     */
    @ApiOperation(value = "下载查询条件模版")
    @GetMapping(value = "downloadQueryTemplate")
    public void downloadQueryTemplate(HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iKshzService.downloadQueryTemplate(response);
    }


    /**
     * 包含矿山历史的矿山信息查询
     */
     @ApiOperation("包含矿山历史的矿山信息查询")
     @PostMapping("/includeHisKshzPage")
    public CommonResult<Page<KsxxhzVo>> includeHisKshzPage(@RequestBody @Valid CxtjMhtj cxtjMhtj) {
        return CommonResult.data(iKshzService.includeHisKshzPage(cxtjMhtj));
    }


    /**
     * 查询统计-矿山信息查询总计
     */
    @ApiOperation("查询统计-矿山信息查询总计")
    @PostMapping("/queryKshzCount")
    public CommonResult<KsxxcxhjVo> queryKshzCount(@RequestPart(value = "file", required = false) MultipartFile file, // 新增：接收文件流
                                                   @Validated  CxtjMhtj cxtjMhtj) {
        return CommonResult.data(iKshzService.queryKshzCount(cxtjMhtj,file));
    }

    /**
     * 查询统计-矿产地信息查询总计
     */
    @ApiOperation("查询统计-矿产地信息查询总计")
    @PostMapping("/queryKcdxxCount")
    public CommonResult<KsxxcxhjVo> queryKcdxxCount(@RequestBody @Valid CxtjMhtj cxtjMhtj) {
        return CommonResult.data(iKshzService.queryKcdxxCount(cxtjMhtj));
    }

    /**
     * 查询统计-矿产地信息查询
     */
    @ApiOperation("查询统计-矿产地信息查询")
    @PostMapping("/queryKcdxxhzPage")
    public CommonResult<Page<KsxxhzVo>> queryKcdxxhzPage(@RequestBody @Valid CxtjMhtj cxtjMhtj) {
        return CommonResult.data(iKshzService.queryKcdxxhzPage(cxtjMhtj));
    }

    /**
     * 全县年度保有量折线图
     *
     * @param kcdm 矿产代码
     * @author Kevin
     * @since 2024/7/19 23:01
     */
    @ApiOperation("全县年度保有量折线图")
    @GetMapping("/lineChartXian")
    public CommonResult<Chart<Double>> lineChartXian(@ApiParam(name = "kcdm", value = "矿种") @RequestParam Integer kcdm) {
        Chart<Double> chart = iKshzService.lineChartXian(kcdm);
        return CommonResult.data(chart);
    }

    /**
     * 年度各类矿产地统计饼状图
     *
     * @param nd 年度
     * @author Kevin
     * @since 2024/7/19 23:01
     */
    @ApiOperation("年度各类矿产地统计饼状图")
    @GetMapping("/barChartXianKcd")
    public CommonResult<List<Map>> barChartXianKcd(@ApiParam(name = "nd", value = "年度") @RequestParam Integer nd) {
        List<Map> list = iKshzService.barChartXianKcd(nd);
        return CommonResult.data(list);
    }

    /**
     * 年度各类矿产地统计柱状图
     *
     * @param nd 年度
     * @author Kevin
     * @since 2024/7/19 23:01
     */
    @ApiOperation("年度各类矿产地统计柱状图")
    @GetMapping("/lineChartXianKcd")
    public CommonResult<CommonChart> lineChartXianKcd(@ApiParam(name = "nd", value = "年度") @RequestParam Integer nd) {
        CommonChart chart = iKshzService.lineChartXianKcd(nd);
        return CommonResult.data(chart);
    }

    /**
     * 年度矿产地勘查程度统计饼状图
     *
     * @param nd 年度
     * @author Kevin
     * @since 2024/7/19 23:01
     */
    @ApiOperation("年度矿产地勘查程度统计饼状图")
    @GetMapping("/barChartXianKccd")
    public CommonResult<List<Map>> barChartXianKccd(@ApiParam(name = "nd", value = "年度") @RequestParam Integer nd) {
        List<Map> list = iKshzService.barChartXianKccd(nd);
        return CommonResult.data(list);
    }

    /**
     * 年度矿产地规模统计饼状图
     *
     * @param nd 年度
     * @author Kevin
     * @since 2024/7/19 23:01
     */
    @ApiOperation("年度矿产地规模统计饼状图")
    @GetMapping("/barChartXianGm")
    public CommonResult<List<Map>> barChartXianGm(@ApiParam(name = "nd", value = "年度") @RequestParam Integer nd) {
        List<Map> list = iKshzService.barChartXianGm(nd);
        return CommonResult.data(list);
    }


    @ApiOperation("查询统计同步字段")
    @GetMapping("/getCxtjsljs")
    public CommonResult<String>  getCxtjsljs(
    ) {
        iKshzService.getCxtjsljs();
        return  CommonResult.ok();
    }


}
